import math


class Solution:
    def maxPoints(self, points: list) -> int:
        """这题的精度很难处理,暂时没想到很好的方法"""
        line_dic, mid_list, length, mid_res = {}, [], len(points), 0
        if length < 2:
            return length
        for i in range(length):
            for j in range(i+1, length):
                if points[i][0] == points[j][0] and points[i][1] == points[j][1]:
                    mid_list.append(points[i])
                    continue
                if points[i][0] == points[j][0]:
                    k = "inf"
                    c = -points[i][0]
                else:
                    k = ((points[i][1] - points[j][1]) * 1000000 / (points[i][0] - points[j][0]))
                    c = ((points[i][1] - k * points[i][0] / 1000000) * 1000000)
                    k //= 1
                    c //= 1
                if (k, c) not in line_dic:
                    line_dic[(k, c)] = 1
                else:
                    line_dic[(k, c)] += 1
        for lists in mid_list:
            if not line_dic:
                return length
            for tuples in line_dic:
                if tuples[0] == "inf":
                    if lists[0] == tuples[1]:
                        line_dic[tuples] += 1
                else:
                    if (tuples[0] * lists[0] + tuples[1]) / 1000000 - lists[1] < 1:
                        line_dic[tuples] += 1
        for tuples in line_dic:
            mid_res = max(mid_res, line_dic[tuples])
        res = int((1 + math.sqrt(1 + 8 * mid_res)) / 2)
        return res


a = Solution()
# print(a.maxPoints([[0, 0], [0, 0]]))  # 3
# print(a.maxPoints([[1, 1], [2, 2], [3, 3]]))  # 3
# print(a.maxPoints([[1, 1], [2, 2], [3, 3], [3, 3]]))  # 4
# print(a.maxPoints([[1, 1], [3, 2], [5, 3], [4, 1], [2, 3], [1, 4]]))  # 4
# print(a.maxPoints([[3, 1], [12, 3], [3, 1], [-6, -1]]))  # 4
print(a.maxPoints([[-435,-347],[-435,-347],[609,613],[-348,-267],[-174,-107],[87,133],[-87,-27],[-609,-507],[435,453],
                   [-870,-747],[-783,-667],[0,53],[-174,-107],[783,773],[-261,-187],[-609,-507],[-261,-187],[-87,-27],
                   [87,133],[783,773],[-783,-667],[-609,-507],[-435,-347],[783,773],[-870,-747],[87,133],[87,133],
        [870,853],[696,693],[0,53],[174,213],[-783,-667],[-609,-507],[261,293],[435,453],[261,293],[435,453]]))  # 37
